package day06.JDK8Demo;

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;

public class Lian10 {
    public static void main(String[] args) {
        LocalDateTime time1 = LocalDateTime.of(2020, 1, 1, 13, 14, 15);
        LocalDateTime time2 = LocalDateTime.of(2020, 1, 2, 3, 4, 5);
        Duration between = Duration.between(time1, time2);
        System.out.println("秒为"+between.getSeconds());
        System.out.println("毫秒为"+between.toMillis());
        System.out.println("纳秒为"+between.toNanos());
        System.out.println("-----------");

        LocalDate p1 = LocalDate.of(2020, 8, 21);
        LocalDate p2 = LocalDate.of(2020, 10, 1);
        Period between1 = Period.between(p1, p2);
        System.out.println("本月间隔为"+between1.getDays());



    }
}
